package com.book.controller;

import com.book.config.SystemConfig;
import com.book.entity.TbBook;
import com.book.entity.TbUser;
import com.book.service.TbMeService;
import com.book.vo.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.List;

/**
 * (TbMe)表控制层
 *
 * @author makejava
 * @since 2024-11-07 19:53:31
 */
@RestController
@RequestMapping("api/tbMe")
@Tag(name = "用户收藏的图书")
public class TbMeController{
    /**
     * 服务对象
     */
    @Resource
    private TbMeService service;

    @Operation(summary = "收藏图书")
    @GetMapping("/meAdd")
    public R meAdd(HttpServletRequest request,Integer bookId){
        String token = request.getHeader(SystemConfig.HEADER_TOKEN);
        return service.meAdd(token,bookId);
    }

    @Operation(summary = "查询用户收藏的图书")
    @GetMapping("/findMe")
    public R findMe(HttpServletRequest request,Integer bookId){
        String token = request.getHeader(SystemConfig.HEADER_TOKEN);
        return service.findMe(token,bookId);
    }

    @Operation(summary = "删除用户收藏的图书")
    @GetMapping("/deleteMe")
    public R deleteMe(HttpServletRequest request,Integer bookId){
        String token = request.getHeader(SystemConfig.HEADER_TOKEN);
        return service.deleteMe(token,bookId);
    }


    @Operation(summary = "我的图书")
    @GetMapping("/myBook")
    public R myBook(HttpServletRequest request){
        String token = request.getHeader(SystemConfig.HEADER_TOKEN);
        return service.mybook(token);
    }

}

